import { listClassification } from "@/api/questionBank/management";

const state = {
  classification: [],
  node:null
};

const mutations = {
  CLASS_IFICATION: (state, view) => {
    state.classification = view;
  },
  SET_NODE:(state,val)=>{
    state.node=val
  }
};

const actions = {
  actionClassification({ dispatch, state, commit }, view) {
    return new Promise((resolve) => {
      if (state.classification.length != 0) {
        resolve(state.classification);
      } else {
        listClassification().then((res) => {
          commit("CLASS_IFICATION", res.data);
          resolve(res.data);
        });
      }
    });
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
